<template>
  <div>
    新闻
    <div v-if="has">
      <div v-html="content"></div>
    </div>
    <div v-else>没有数据</div>
  </div>
</template>

<script setup lang="ts">
let route = useRoute();
let content: string;
const has = ref(false);
const path = ref(route.fullPath);
// 假设你有一个包含编码中文字符的URL路径
// 使用JavaScript内置的decodeURIComponent函数解码路径中的编码部分
path.value = decodeURIComponent(path.value);
// 检查URL是否包含问号
if (path.value.indexOf("?" || "/?") !== -1) {
  // 如果包含问号，则移除问号及其后面的所有内容
  path.value = path.value.substring(0, path.value.indexOf("?"));
}
// console.log("path", path.value);
let result = await useFetch("/api/post/getnews", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify(path.value),
});
if (result.data.value?.code == 2000) {
  content = result.data.value.data[0].content;
  has.value = true;
} else if (result.data.value?.code == 4003) {
  location.reload();
}


onMounted(() => {

  let goal = document.getElementsByClassName("style-local-57-m5")[0]  
})

// console.log("result", result.data.value?.code);
onMounted(() => {
  // console.log('挂载后');
  let goal = document.getElementsByClassName("style-local-57-m5")[0];
  // console.log('goal',goal);
});

</script>

<style scoped>
:deep(.h-row) {
  width: 100%;
}
:deep(.h-section-grid-container) {
  width: 100%;
}
:deep(.style-local-57-m4) {
  position: relative;
  width: 100%;
  margin-bottom: 20px;
  padding: 0 25px 25px 25px;
}
:deep(.style-local-57-m5) {
  padding: 2%;
  box-shadow: 0px 0px 20px #ccc;
  border-radius: 5px;
  width: 100%;
  :deep(.style-local-57-m5) {
    padding: 2%;
    box-shadow: 0px 0px 20px #ccc;
    border-radius: 5px;
    width: 100%;
  }
  :deep(.colibri-word-wrap) {
    color: rgb(15, 15, 15);
    width: 80%;
    margin: 10px 0;
  }
  :deep(.style-local-57-m6-outer) {
    color: rgb(180, 179, 179);
    width: 80%;
    font-size: 14px;
    margin: 10px 0;
  }
  :deep(.style-local-57-m9-outer) {
    color: rgb(180, 179, 179);
    position: absolute;
    right: 5%;
    top: 50%;
    transform: translateY(-50%);
    transition: all 0.5s;
  }
  :deep(.style-local-57-m9-outer):hover {
    color: rgb(15, 15, 15);
  }
}
</style>
